var express = require('express');
var router = express.Router();

const warehouse = require("../controller/warehouse");
const auth = require("../controller/auth");

// 需要登录权限的路由
/**
 * @openapi
 * /warehouses/add:
 *   post:
 *     tags:
 *       - Warehouses
 *     summary: 新增仓库
 *     description: 此接口允许管理员添加新的仓库。
 *     security:
 *       - bearerAuth: []
 *     requestBody:
 *       required: true
 *       content:
 *         application/json:
 *           schema:
 *             type: object
 *             properties:
 *               name:
 *                 type: string
 *                 description: 仓库名称
 *               location:
 *                 type: string
 *                 description: 仓库位置
 *               size:
 *                 type: string
 *                 description: 仓库大小
 *               totalCapacity:
 *                 type: integer
 *                 description: 总容量
 *               maxHeight:
 *                 type: integer
 *                 description: 最大高度
 *               description:
 *                 type: string
 *                 description: 仓库描述
 *               manager:
 *                 type: string
 *                 description: 仓库经理
 *               active:
 *                 type: boolean
 *                 description: 是否激活
 *               equipment:
 *                 type: array
 *                 items:
 *                   type: string
 *                   description: 仓库设备列表
 *               securityLevel:
 *                 type: string
 *                 description: 安全级别
 *               storageType:
 *                 type: string
 *                 description: 存储类型
 *     responses:
 *       201:
 *         description: 仓库信息新增成功
 *         content:
 *           application/json:
 *             schema:
 *               type: object
 *               properties:
 *                 message:
 *                   type: string
 *                   description: 操作成功的消息
 *                 lastID:
 *                   type: integer
 *                   description: 新增仓库的ID
 *       401:
 *         description: 未授权访问，只有登录的管理员可以访问此接口
 *       400:
 *         description: 请求格式错误或数据不完整
 */
router.post("/add", auth.isLogin,auth.isAdmin, warehouse.add);
//查找指定仓库id
/**
 * @openapi
 * /warehouses/find/{id}:
 *   get:
 *     tags:
 *       - Warehouses
 *     summary: 查询指定仓库详情
 *     description: 此接口允许管理员查询特定ID的仓库详情。
 *     security:
 *       - bearerAuth: []
 *     parameters:
 *       - in: path
 *         name: id
 *         required: true
 *         description: 仓库ID
 *         schema:
 *           type: string
 *     responses:
 *       201:
 *         description: 查找仓库信息成功
 *         content:
 *           application/json:
 *             schema:
 *               type: object
 *               properties:
 *                 message:
 *                   type: string
 *                   description: 操作成功的消息
 *                 data:
 *                   type: object
 *                   properties:
 *                     // 仓库信息字段...
 *       401:
 *         description: 未授权访问，只有登录的管理员可以访问此接口
 *       404:
 *         description: 仓库ID不存在
 *       500:
 *         description: 服务器内部错误
 */
router.get("/find/:id", auth.isLogin,auth.isAdmin, warehouse.find);
//查找所有仓库
/**
 * @openapi
 * /warehouses/findAll:
 *   get:
 *     tags:
 *       - Warehouses
 *     summary: 查询所有仓库详情
 *     description: 此接口允许管理员获取所有仓库的列表。
 *     security:
 *       - bearerAuth: []
 *     responses:
 *       201:
 *         description: 获取仓库列表成功
 *         content:
 *           application/json:
 *             schema:
 *               type: object
 *               properties:
 *                 message:
 *                   type: string
 *                   description: 操作成功的消息
 *                 data:
 *                   type: array
 *                   items:
 *                     type: object
 *                     properties:
 *                       // 仓库信息字段...
 *       401:
 *         description: 未授权访问，只有登录的管理员可以访问此接口
 *       500:
 *         description: 服务器内部错误
 */
router.get("/findAll", auth.isLogin,auth.isAdmin, warehouse.findAll);
//删除指定仓库
/**
 * @openapi
 * /warehouses/remove/{id}:
 *   delete:
 *     tags:
 *       - Warehouses
 *     summary: 删除指定仓库
 *     description: 此接口允许管理员删除特定ID的仓库。
 *     security:
 *       - bearerAuth: []
 *     parameters:
 *       - in: path
 *         name: id
 *         required: true
 *         description: 仓库ID
 *         schema:
 *           type: string
 *     responses:
 *       201:
 *         description: 删除仓库信息成功
 *         content:
 *           application/json:
 *             schema:
 *               type: object
 *               properties:
 *                 message:
 *                   type: string
 *                   description: 操作成功的消息
 *                 data:
 *                   type: object
 *                   properties:
 *                     // 仓库信息字段...
 *       401:
 *         description: 未授权访问，只有登录的管理员可以访问此接口
 *       404:
 *         description: 仓库ID不存在或无法删除
 *       500:
 *         description: 服务器内部错误
 */
router.delete("/remove/:id", auth.isLogin,auth.isAdmin, warehouse.remove);
//更新仓库信息
/**
 * @openapi
 * /warehouses/update/{id}:
 *   put:
 *     tags:
 *       - Warehouses
 *     summary: 更新仓库
 *     description: 此接口允许管理员更新特定ID的仓库信息。
 *     security:
 *       - bearerAuth: []
 *     parameters:
 *       - in: path
 *         name: id
 *         required: true
 *         description: 仓库ID
 *         schema:
 *           type: string
 *     requestBody:
 *       required: true
 *       content:
 *         application/json:
 *           schema:
 *             type: object
 *             properties:
 *               name:
 *                 type: string
 *                 description: 仓库名称
 *               location:
 *                 type: string
 *                 description: 仓库位置
 *               size:
 *                 type: string
 *                 description: 仓库大小
 *               totalCapacity:
 *                 type: integer
 *                 description: 总容量
 *               maxHeight:
 *                 type: integer
 *                 description: 最大高度
 *               description:
 *                 type: string
 *                 description: 仓库描述
 *               manager:
 *                 type: string
 *                 description: 仓库经理
 *               active:
 *                 type: boolean
 *                 description: 是否激活
 *               equipment:
 *                 type: array
 *                 items:
 *                   type: string
 *                   description: 仓库设备列表
 *               securityLevel:
 *                 type: string
 *                 description: 安全级别
 *               storageType:
 *                 type: string
 *                 description: 存储类型
 *     responses:
 *       200:
 *         description: 仓库信息更新成功
 *         content:
 *           application/json:
 *             schema:
 *               type: object
 *               properties:
 *                 message:
 *                   type: string
 *                   description: 操作成功的消息
 *                 warehouseId:
 *                   type: string
 *                   description: 仓库ID
 *       401:
 *         description: 未授权访问，只有登录的管理员可以访问此接口
 *       404:
 *         description: 仓库ID不存在或无法更新
 *       500:
 *         description: 服务器内部错误
 */
router.put("/update/:id", auth.isLogin,auth.isAdmin, warehouse.update);

module.exports = router;
